import React, { lazy, Suspense } from "react";

import LoginDom from "../views/login";
import HomeDom from "../views/Home/home";
import NormalTable from "../views/table/normalTable";
import TitleTable from "../views/table/titleTable";
import CheckboxTable from "../views/table/checkboxTable";
import SimpleForm from "../views/form/simpleForm";
import NotFound from "../views/notFound/NotFound";
import BigSreen from "../views/bigsSreen/index";
import TableForm from "../views/form/tableForm";

// 懒加载
// const TreeTable = lazy(() => import("../views/form/treeTable"));

import { createBrowserRouter, redirect, RouterProvider, Navigate } from "react-router-dom";

export let routerArr = [
  {
    path: "",
    element: <LoginDom />,
  },
  {
    path: "/",
    element: <LoginDom />,
  },
  {
    path: "/login",
    element: <LoginDom />,
  },
  {
    path: "*",
    element: <NotFound />, // 404页面路由
  },
  {
    path: "/bigSreen",
    element: <BigSreen />, // 大屏
  },
  {
    path: "/home",
    element: <HomeDom />,
    name: "主页",

    children: [
      {
        path: "",
        element: <Navigate to="normalTable" />,
      },

      {
        path: "normalTable",
        element: <NormalTable />,
        name: "普通表格",
      },
      {
        path: "titleTable",
        element: <TitleTable />,
        name: "表头表格",
      },
      {
        path: "treeTable",
        element: lazy(() => import("../views/table/treeTable")),
        name: "树表格",
      },
      {
        path: "checkboxTable",
        element: <CheckboxTable />,
        name: "多选表格",
      },
      {
        path: "simpleForm",
        element: <SimpleForm />,
        name: "简单表单",
      },
      {
        path: "tableForm",
        element: <TableForm />,
        name: "表格表单",
      },
    ],
  },
];

export let routers = createBrowserRouter(routerArr);
